package com.example.text.controller;


import com.example.text.entity.Inware;
import com.example.text.entity.Outware;
import com.example.text.entity.Result;
import com.example.text.service.OutWareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/out")
public class OutWareController {

    @Autowired
    OutWareService outWareService;

    //查询全部
    @GetMapping("/selectAllOrder")
    public Result selectAll() {
        List<Outware> outwareList = outWareService.selectAllOrder();
        return Result.success(outwareList);
    }

    //根据订单号查询
    @GetMapping("/selectByOrder/{OutWareOrder}")
    public Result selectByOrder(@PathVariable String OutWareOrder) {
        Outware outware = outWareService.selectByOrder(OutWareOrder);
        return Result.success(outware);


    }


    @PostMapping("/delete/{OutWareId}")
    public Result delete(@PathVariable Integer OutWareId){
        outWareService.deleteOrder(OutWareId);
        return Result.success();
    }

    @PostMapping("/add")
    public Result add(@RequestBody Outware outware ){
        outWareService.insertWare(outware);
        return Result.success();
    }

}
